var removeNthFromEnd = function(head, n) {
    
    let add = 0
    const dummyHead = new ListNode(0);
    let result = dummyHead
    dummyHead.next = head
    while(head!==null){
        head=head.next
        add++
    }
    for(let i=0;i<add-n;i++){
        result = result.next
    }
    result.next = result.next.next
    return dummyHead.next
};